package ship;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;

public class ShipComparator implements Comparator<Ship>{

	@Override
	public int compare(Ship ship1, Ship ship2) {


		return ship1.getCapacity()-ship2.getCapacity();
	}
public static void main(String[] args) {
	ShipComparator comparator = new ShipComparator();
	ArrayList <Ship> list = new ArrayList <Ship>();
	
	Ship sh = new Ship (400, 7,"Titanic");
	Ship sh1= new Ship (4, 7,"Santa Marina");
	Ship sh2= new Ship (49,7,"Queen Mary");
	
	list.add(sh);
	list.add(sh1);
	list.add(sh2);
	Collections.sort(list, comparator);
	System.out.println(list); 
}
}
